require('../../assets/css/normalize.css')
require('../../assets/css/reset.css')
require('../../assets/fonts/iconfont.css')
require('./login.less');

// 引入DOM相关模块
const doc = require('../../utils/dom.js')
const axios = require('axios')

// 提交验证
// doc.get('.btn').
doc.get('.btn').addEventListener('click', function () {
    let user = doc.get('.user').value
    let pwd = doc.get('.pwd').value
    axios.post('http://fitness.h5.itsource.cn:3701/api/user/login', {
        account: user,
        password: pwd,
    }).then(res => {
        if (res.data.errno === 0) {
            localStorage.setItem("token", res.data.data.token)
            alert('登录成功')
            location.href = 'index.html'
        } else {
            alert(res.data.message)
        }
    })
})